<fieldset class="layui-elem-field">
    <legend>合同详情</legend>
    <!--<div class="layui-field-box">-->
        <!--<textarea name="desc"disabled class="layui-textarea">{$content}</textarea>-->
        <!--&lt;!&ndash;<textarea class="layui-textarea" id="LAY_demo1" style="display: none" name="content">{$content}</textarea>&ndash;&gt;-->
    <!--</div>-->

    <div class="layui-form-item">
        <!--<label class="layui-form-label">合作内容</label>-->
        <!--<div class="layui-inline">-->
            <textarea class="layui-textarea" id="LAY_demo1" style="display: none" name="content">{$content}</textarea>
        <!--</div>-->
    </div>

    <div class="layui-form-item" style="text-align: right;margin-right: 20px">
        <a href="{:url('Contract/contractlist')}" class="layui-btn layui-btn-primary">返回</a>
    </div>
</fieldset>
<script>
    layui.use(['layedit','element', 'table', 'layer', 'form', 'upload'],function(){
        var layer = layui.layer;
        var form = layui.form;
        var layedit = layui.layedit
            ,$ = layui.jquery;
        layedit.set({
            uploadImage: {
                url: '{:url("Common/uploads")}' //接口url
            }
        });
        //构建一个默认的编辑器
        var index = layedit.build('LAY_demo1',{
            tool: [
            ]
        });

        //编辑器外部操作
        var active = {
            content: function(){
                alert(layedit.getContent(index)); //获取编辑器内容
            }
            ,text: function(){
                alert(layedit.getText(index)); //获取编辑器纯文本内容
            }
            ,selection: function(){
                alert(layedit.getSelection(index));
            }
        };
        form.on('submit(ajax-layedit)', function (data) {
            var loading = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            var url = data.form.action;
            var method = data.form.method;
            var d = data.field;
            console.log(layedit.getContent(layedit_index));
            d.content = layedit.getContent(layedit_index);
            $.ajax({
                type: method,
                url: url,
                data: data.field,
                dataType: 'json',
                success: function (res) {
                    layer.close(loading);
                    msg = res.msg ? res.msg : '网络错误';
                    layer.msg(msg);
//                    jumpUrl = res.jumpUrl;
//                    if (res.code == 200) {
//                        if (jumpUrl) {
//                            window.location.href = jumpUrl;
//                        } else {
//                            window.location.reload();
//                        }
//                    }
                },
                error: function (res) {
                    layer.close(loading);
                    layer.msg("网络错误");
                }
            });
            return false;
        });
        //自定义工具栏
        layedit.build('LAY_demo2', {
            tool: [ 'link', 'unlink', '|', 'left', 'center', 'right']
            ,height: 100
        })
    });
</script>
